﻿#region 命名空间

using System;
using System.Web;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using WinnerCMS.Model;
using WinnerCMS.Common;
using WinnerCMS.Data;

#endregion

namespace WinnerCMS.BLL.PageFactory.ManageHtml
{
    /// <summary>
    /// 生成单页处理类
    /// </summary>
    public static class MakeSinglePage
    {
        /// <summary>
        /// 生成内容页
        /// </summary>
        /// <param name="id"></param>
        public static void ContentPageHTML(int id)
        {
            Thread th = new Thread(ContentPageHTML);
            th.Start(id);
        }

        /// <summary>
        /// 生成内容页
        /// </summary>
        /// <param name="id"></param>
        private static void ContentPageHTML(object id)
        {
            int contentId = Convert.ToInt32(id);
            Core model = new CoreManage().GetBaseInfo(contentId);

            if (model == null)
            {
                return;
            }
            if (model.TemplateFileName.Length == 0)
            {
                return; //没有设置模板就跳过生成
            }
            Category cinfo = CategoryManage.GetInfo(model.CategoryId);
            if (cinfo.UrlStyle == 0)
            {
                return;
            }

            string url = string.Format("{0}/Templates/{1}?CategoryId={2}&ID={3}&Method=Save", WebConfig.DomainName,
                model.TemplateFileName, model.CategoryId, contentId);

            SaveHTML.GetWebCode(url);
        }
    }
}